package com.wanbangee.marksystem.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import com.wanbangee.marksystem.entities.MAnswerSheetRecord;
import com.wanbangee.marksystem.entities.MExamMarker;
import com.wanbangee.marksystem.entities.SScoreDetail;
@Mapper
public interface MExamMarkerDao {
	/**
	 * 插入阅卷组明细
	 * @param mExamMarker
	 */
	boolean InsertIntoExamMarker(@Param("MExamMarker")MExamMarker mExamMarker); 
	
	/**
	 * 查询该题是单评还是多评
	 * @param examId
	 * @param subId
	 * @param topicNo
	 * @return
	 */
	public Integer selectScoreTypeByExamIdAndSubIdAndTopicNo(@Param("examId")Integer examId,@Param("subId")Integer subId,@Param("topicNo")String topicNo);
	
	//=============================质量抽查==============================
		/**
		 * 通过考试 Id 和科目 Id 以及题号来获取阅卷组信息
		 * @param examId
		 * @param examSubId
		 * @param topicNo
		 * @return
		 */
		public List<MExamMarker> selectMExamMarkerInfoByExamIdExamSubIdTopicNo(Integer examId,Integer examSubId,Integer topicNo);

		/**
		 * 根据 marker id 查询信息，用于图表列表显示
		 * @param markerId
		 * @return
		 */
		public MExamMarker selectMExamMarkerByMarkerId(Integer markerId);

		/**
		 * 通过 markerId 查询考试成绩信息，用于列表图表显示
		 * @param markerId
		 * @param examId
		 * @param examSubId
		 * @param scoreType
		 * @return
		 */
		public List<SScoreDetail> selectScoreByMarkerIdAndExamIdAndExamSubIdAndScoreType(Integer markerId,Integer examId,Integer examSubId,Integer scoreType);

		/**
		 * 列表显示
		 * @param examId
		 * @param examSubId
		 * @param topicNo
		 * @return
		 */
		public List<MExamMarker> selectMExamMarkerList(Integer examId,Integer examSubId,Integer topicNo);
		
		
		/**
		 * 求最大值、平均分、最小值
		 * @param examId
		 * @param examSubId
		 * @param topicNo
		 * @param scoreType
		 * @param markerId
		 * @return
		 */
		public Map selectSScoreDetailAvgMaxMin(Integer examId,Integer examSubId,Integer topicNo,Integer scoreType,Integer markerId);

		/**
		 * 求满分卷数目
		 * @param examId
		 * @param examSubId
		 * @param topicNo
		 * @param scoreType
		 * @param markerId
		 * @param topicScore
		 * @return
		 */
		public Integer selectSScoreDetailfullMarkerNum(Integer examId,Integer examSubId,Integer topicNo,Integer scoreType,Integer markerId,Double topicScore);

		/**
		 * 求零分卷数目
		 */
		public Integer selectSScoreDetailzeroExamNum(Integer examId,Integer examSubId,Integer topicNo,Integer scoreType,Integer markerId);

		/**
		 * 求问题卷数目
		 */
		public Integer selectSScoreDetailproblemExamNum(Integer examId,Integer examSubId,Integer topicNo,Integer markerId);

		/**
		 * 求打回的试卷数目
		 */
		public Integer selectSScoreDetailrepeatExamNum(Integer examId,Integer examSubId,Integer topicNo,Integer markerId);

		/**
		 * 求已经阅卷的数目
		 */
		public Integer selectSScoreDetailalreadyExamNum(Integer examId,Integer examSubId,Integer topicNo,Integer markerId);

		/**
		 * 查询考试 Id 、考试名、科目 Id、科目名
		 */
		public List<MExamMarker> selectMExamMarkerByTeaIdAndSchId(Integer schId,Integer teaId);
		
		/**
		 * 进度监控列表显示
		 */
		public List<MExamMarker> selectMExamMarkerByExamIdAndExamSubId(Integer examId,Integer examSubId);


		/**
		 *  已经阅卷的仲裁数目
		 */ 
		public Integer selectSScoreDetailalreadyTeaNum(Integer examId,Integer examSubId,Integer topicNo,Integer markerId);
		 /**
		  * 全部需要阅卷的仲裁数目 
		 */
		public Integer selectSScoreDetailallTeaNum(Integer examId,Integer examSubId,Integer topicNo,Integer markerId);
		//=============================进度监控==============================

		/**
		 * 添加阅卷人
		 * @param marker
		 * @return
		 */
		public Integer insertMExamMarker(MExamMarker marker);
		
		/**
		 * 分解阅卷任务的候选人列表
		 * @return
		 */
		public List<MExamMarker> selectMExamMarkerInfoByExamIdAndExamSubIdAndTopicNoOnTea(Integer examId,Integer examSubId,Integer topicNo);
		
		/**
		 * 分解阅卷任务之-更新阅卷组表的数量
		 */
		public Integer updateMExamMarkerByMarkerId(Integer markerId,Integer allocation_num,Integer state);

	 
		/**
		 * 查询阅卷表信息-用于分解阅卷人 
		 */
		public MExamMarker selectMExamMarkerByMarkerIdOnResolver(Integer markerId);
		
		/**
		 * 重评列表显示
		 * @param teaId
		 * @param schId
		 * @return
		 */
		public List<MExamMarker> selectRepeatListByTeaIdSchId(Integer teaId,Integer schId);
		
		/**
		 * 查询已经完成重评阅卷的数目
		*/
		public Integer selectAlreadyRepeatExamNum(Integer examId,Integer examSubId,Integer topicNo,Integer markerId,Integer teaNo);
		
		
		
		//===============================================================================================================
		
		/**
		 * 查询出特殊卷信息，用于插入答题记录表
		 * @param examId
		 * @param examSubId
		 * @param markerId
		 * @param scoreId
		 * @return
		 */
		public MAnswerSheetRecord selectAnswerSheetRecordInfo(@Param("examId")Integer examId,@Param("examSubId")Integer examSubId,@Param("markerId")Integer markerId,@Param("scoreId")Integer scoreId);
		
		//-------------------------------------仲裁打分------------------------------------
		/**
		 * 根据仲裁老师id，查询考试信息
		 * @param teaId
		 * @param schId
		 * @return
		 */
		public List<MExamMarker> selectArbitrationExamInfoByTeaIdAndSchId(@Param("teaId")Integer teaId,@Param("schId")Integer schId);
		
		
		//
		/**
		 * 该题已完成仲裁任务数
		 * @param examId
		 * @param examSubId
		 * @param topicNo
		 * @param teaId
		 * @return
		 */
		public Integer selectAlreadyArbitrationCount(@Param("examId")Integer examId,@Param("examSubId")Integer examSubId,@Param("topicNo")String topicNo,@Param("teaId")Integer teaId);
		
		//
		/**
		 * 该题仲裁任务数
		 * @param examId
		 * @param examSubId
		 * @param topicNo
		 * @param teaId
		 * @return
		 */
		public Integer selectArbitrationTestCount(@Param("examId")Integer examId,@Param("examSubId")Integer examSubId,@Param("topicNo")String topicNo,@Param("teaId")Integer teaId);
		
		//
		/**
		 * 全部未完成仲裁任务数
		 * @param examId
		 * @param examSubId
		 * @param teaId
		 * @return
		 */
		public Integer selectAllArbitrationCount(@Param("examId")Integer examId,@Param("examSubId")Integer examSubId,@Param("teaId")Integer teaId);
		
		//-------------------------------------阅卷打分------------------------------------
		/**
		 * 根据阅卷老师id，学校id，查询考试信息
		 * @param teaId
		 * @param schId
		 * @return
		 */
		public List<MExamMarker> selectExamInfoByExamIdAndTopicNo(@Param("teaId")Integer teaId,@Param("schId")Integer schId);
		
		/**
		 * 	查询已阅卷题目数
		 * @param examId
		 * @param examSubId
		 * @param markId
		 * @param topicNo
		 * @return
		 */
		public Integer selectAlreadyCountByExamIdExamSubIdMarkIdTopicIdTeaId(@Param("examId")Integer examId,@Param("examSubId")Integer examSubId,@Param("markId")Integer markId,@Param("topicNo")String topicNo,@Param("teaId")Integer teaId);
		
		/**
		 * 查询总阅卷题目数
		 * @param examId
		 * @param examSubId
		 * @param markId
		 * @param topicNo
		 * @param teaId
		 * @return
		 */
		public Integer selectAllCountByExamIdExamSubIdMarkIdTopicIdTeaId(@Param("examId")Integer examId,@Param("examSubId")Integer examSubId,@Param("markId")Integer markId,@Param("topicNo")String topicNo,@Param("teaId")Integer teaId);
		
		
		/**
		 * 查询阅卷人数
		 * @param examId
		 * @param examSubId
		 * @param markId
		 * @param topicNo
		 * @param teaId
		 * @return
		 */
		public Integer selectallMExamMarkerTeacherCountByExamIdExamSubIdMarkIdTopicIdTeaId(@Param("examId")Integer examId,@Param("examSubId")Integer examSubId,@Param("markId")Integer markId,@Param("topicNo")String topicNo,@Param("teaId")Integer teaId);
}
